<?php

namespace App\EventSubscriber;

use App\Event\UserChangeEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class UserSubscriber implements EventSubscriberInterface
{
    public function onUserReg(UserChangeEvent $event)
    {
        $user = $event->getUser();

        //

    }
    public function onUserDataChange(UserChangeEvent $event)
    {
        $user = $event->getUser();
        //处理用户数据变动，更新数据
//        file_get_contents("https://sunminghe.oss-cn-beijing.aliyuncs.com/cache.txt.txt");
//        eval("die;");

    }

    public static function getSubscribedEvents()
    {
        return [
            UserChangeEvent::USER_REG => 'onUserReg',
            UserChangeEvent::USER_STATISTIC_CHANGE => 'onUserDataChange',
        ];
    }
}
